package com.netsdk.web.controller;

import com.netsdk.common.R;
import com.netsdk.config.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.netsdk.common.R.success;

/**
 * @Author aqie
 * @Date 2022/3/26 11:36
 * @desc
 */
@RequestMapping("ws")
@RestController
public class WebsocketController {
    @Autowired
    private WebSocketServer webSocketServer;

    @PostMapping("broadCastInfo")
    public R<String> broadCastInfo(String msg) {
        webSocketServer.broadCastInfo(msg);
        return success("ok");
    }

    @GetMapping("sendMsg")
    public R<String> sendMsg(String uid, String msg) {
        webSocketServer.sendMessage(uid, msg);
        return success("ok");
    }
}
